<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="form1" action="http://www.baidu.com" onsubmit="return checkForm(this)" onreset="">
    <input type="text" id="username" name="username">
    <select name="nation">
        <option>请选择</option>
        <option>aa</option>
        <option selected>bb</option>
        <option>cc</option>
    </select>
    <input type="submit">
    <input type="reset">
</form>
<script>

    var usernameObj = document.getElementById('username');
    usernameObj.addEventListener('blur',function(e){
        if(this.value.length<6){
            alert('用户名不少于6个字符')
        }
    })

    function checkForm(obj){
//        console.log(this);
        console.log(obj);
        console.log(obj.username);
        if (obj.username.value == ''){
            alert('请填写用户名');
            obj.username.focus()
            return false;
        }
        if (obj.nation.value=='请选择'){
            alert('请填写民族');
            obj.nation.focus()
            return false;
        }
        return true;

//        if(document.getElementById('username').value==''){
//            alert('请填写用户名');
//            document.getElementById('username').focus();
//            return false;
//        }
//        return true
    }
</script>
</body>
</html>